package com.adaxi.adc.business.passengertrip.pojo;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class TripDTO {
    private String id;
    private String route;
    private String startDate;
    private String startTime;
    private int numPassengers;
    private int maxSeatCapacity;
    private double price;

    public TripDTO(Trip trip) {
        this.id = trip.getId();
        this.route = trip.getRoute();
        this.startDate = formatDate(trip.getStartDate());
        this.startTime = formatTime(trip.getStartTime());
        this.numPassengers = trip.getNumPassengers();
        this.maxSeatCapacity = trip.getMaxSeatCapacity();
        this.price = trip.getPrice();
    }

    private String formatDate(Date date) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return dateFormat.format(date);
    }

    private String formatTime(Date date) {
        SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
        return timeFormat.format(date);
    }

}
